import sys,svm
model_file = sys.argv[1]
#loading supporting vectors and bias
f = open(model_file)
bias = float(f.readline())
h_alpha, w_alpha, alpha_s,sv_s = svm.read_examples(f)

print >> sys.stderr, "loading testing examples..."
h_test, w_test, answer_s,test_s = svm.read_examples(sys.stdin)

err_count = 0.0
for v,answer in zip(test_s,answer_s):
    # start with the bias
    c = 0
    for sv,alpha in zip(sv_s,alpha_s):
        c += alpha * svm.dot(sv, v)
    print c,
    
    if answer > 0 and c >0:
        print 'TP'
    elif answer>0 and c<0:
        print 'FN'
        err_count += 1
    elif answer < 0 and c <0:
        print 'TN'
    else:
        print 'FP'
        err_count += 1

print 'Accuracy:', (h_test-err_count)/float(h_test)
    